# 封装BROWSER方法
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options


# 使用谷歌无GUI方式获取浏览器实例
def getBrowserByChromeHeadless():
    chromeOptions = Options()
    chromeOptions.add_argument('--headless')
    chromeOptions.add_argument('--disable-gpu')
    browserPath = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
    chromeOptions.binary_location = browserPath
    browser = webdriver.Chrome(chrome_options=chromeOptions)
    return browser


# 使用Selenium获取
def getBrowserBySelenium():
    driverPath = './chromedriver.exe'
    browser = webdriver.Chrome(driverPath)
    return browser


# 使用PhantomJS获取
def getBrowserByPhantomJS():
    driverPath = './phantomjs.exe'
    browser = webdriver.PhantomJS(driverPath)
    return browser
